# Contributor: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: William Rea <sillywilly@gmail.com>

pkgname=goocanvas
pkgver=3.0.0
pkgrel=4
pkgdesc='Cairo canvas widget for GTK'
arch=('loong64' 'x86_64')
url='https://wiki.gnome.org/Projects/GooCanvas'
license=('LGPL')
depends=('gtk3')
makedepends=('git' 'gobject-introspection' 'gtk-doc' 'python-gobject')
_commit=076c374ab05b9ee326e3b7905d3d72197429171e  # tags/3.0.0^0
source=("git+https://gitlab.gnome.org/GNOME/goocanvas.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd $pkgname

  # Fix generating docs
  cp docs/goocanvas2-docs.sgml docs/goocanvas3-docs.sgml
  cp docs/goocanvas2-overrides.txt docs/goocanvas3-overrides.txt
  cp docs/goocanvas2-sections.txt docs/goocanvas3-sections.txt
  cp docs/goocanvas2.types docs/goocanvas3.types

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgname
  ./configure --prefix=/usr --enable-gtk-doc
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
}
